<?php
/* @var $this CmppaymentController */
/* @var $model Payment */
/* @var $form CActiveForm */
?>
		<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'payment-form',
			'enableAjaxValidation'=>false,
			)); ?>
		<?php echo $form->hiddenField($model,'zpy_id')?>
		<ul class="form_list form_list2 mt10">
			<li class="title"><span class="fs_14 fw_b">添加/编辑支付方式</span></li>
			<li class="c_f"><span class="tit">支付名称：</span>
				<div class="cont f_l">
					<?php echo $form->textField($model,'zpy_name',array('class'=>'t_ipt w_250','maxlength'=>50))?>
					<?php echo $form->error($model,'zpy_name')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">接口类名称：</span>
				<div class="cont f_l">
					<?php echo $form->textField($model,'class_name',array('class'=>'t_ipt w_250','maxlength'=>50))?>
					<?php echo $form->error($model,'class_name')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">帐户名称：</span>
				<div class="cont f_l">
					<?php echo $form->textField($model,'zpy_payment_user',array('class'=>'t_ipt w_250','maxlength'=>50))?>
					<?php echo $form->error($model,'zpy_payment_user')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">支付账号ID：</span>
				<div class="cont f_l">
					<?php echo $form->textField($model,'zpy_payment_id',array('class'=>'t_ipt w_250','maxlength'=>50))?>
					<?php echo $form->error($model,'zpy_payment_id')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">交易安全校验码：</span>
				<div class="cont f_l">
					<?php echo $form->textField($model,'zpy_payment_key',array('class'=>'t_ipt w_250','maxlength'=>50))?>
					<?php echo $form->error($model,'zpy_payment_key')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">说明：</span>
				<div class="cont f_l">
					<?php echo $form->textArea($model,'zpy_content',array('class'=>'t_area','style'=>'width:455px; height:70px;'))?>
					<?php echo $form->error($model,'zpy_content')?>
				</div>
			</li>
			<li class="c_f"><span class="tit">图标：</span>
				<div class="cont f_l">
					<div class="f_l">
						<?php echo CHtml::image(empty($model->zpy_logo)?'/images/cert_img.jpg.jpg':$model->zpy_logo,'',array('id'=>'img1','width'=>'125','height'=>'47'))?>
					</div>
					<div class=" f_l" style='padding:20px' > 
						<?php echo CHtml::link('上传图标<b class="mem_bgx left"></b><b class="mem_bgx right"></b>'.CHtml::fileField('image','',array('id'=>'uploadimg1','multiple'=>true)),'javascript:',array('class'=>'mem_bgx link_btn filelink mr20','onclick'=>"uploadimg('1')"))?>
						<?php echo $form->hiddenField($model,'zpy_logo',array('id'=>'proimage1'))?>
					</div>
				</div>
			</li>
			<li class="c_f"><span class="tit">是否线上支付：</span>
				<div class="cont f_l">
					<?php echo $form->radioButtonList($model,'zpy_online',Payment::model()->getZpyOnline(),array('class'=>'radio','labelOptions'=>array('class'=>'mr30')))?>
				</div>
			</li>
			<li class="c_f"><span class="tit">是否启用：</span>
				<div class="cont f_l">
					<?php echo $form->radioButtonList($model,'zpy_available',Payment::model()->getAvailable(),array('class'=>'radio','labelOptions'=>array('class'=>'mr30')))?>
				</div>
			</li>
			<li class="c_f"><span class="tit">&nbsp;</span>
				<div class="cont f_l">
					<?php echo CHtml::submitButton(Yii::t('adm','Save Date'),array('class'=>'mem_btn mem_btn20 mr5'))?>
					<?php echo CHtml::submitButton(Yii::t('adm','Reset'),array('class'=>'mem_btn mem_btn07'))?>
				</div>
			</li>
		</ul>	
	<?php $this->endWidget(); ?>

	
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.ui.widget.js"></script>  
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.iframe-transport.js"></script>  
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.fileupload.js"></script>  

<script>  
//上传图片
function uploadimg (id) {
	   $('#uploadimg'+id).fileupload({         	
	        dataType: 'json',       
	        url: '/Attachment/GetAjax',        
	        success: function (json) {
	               if(json.upfile.errors=='1'){
	               		alert(json.upfile.msg);
	               }else if(json.upfile.errors=='2'){
	               		alert(json.upfile.msg);
	               }else{
		                 //修改按钮图标
		            	 $('#img'+id).attr('src',json.upfile.file);
						 //修改按钮文本
		            	 $('#uploadimg'+id).parent().html('修改图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b><input type="file" id="uploadimg'+id+'" multiple name="image"/>');
		            	 //填加删除按钮
		            	 if(!$('#img'+id).parent().parent().find('a')[1]){
		            		 $('#img'+id).parent().parent().find('a').eq(0).after('<a class="mem_bgx link_btn" href="javascript:" onclick="removeimg(\''+id+'\')">删除图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b></a>');
		            	 }
						 //修改隐藏域值
	               		 $('#proimage'+id).attr('value',json.upfile.file);
	               } 	
	        }
	    });
};
//删除图片
function removeimg(id){
	$('#img'+id).parent().parent().find('a').eq(0).html('上传图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b><input type="file" id="uploadimg'+id+'" multiple name="image"/>');
	$('#img'+id).parent().parent().find('a').eq(1).remove();
	$('#img'+id).attr('src','/images/pro_img.jpg');
	$('#proimage'+id).attr('value','');
}


</script>